package com.study.Service.Impl;

import com.study.Entity.Section;
import com.study.Mapper.SectionMapper;
import com.study.Service.SectionService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SectionServiceImpl implements SectionService {
    @Autowired
    private SectionMapper sectionMapper;

    @Override
    public void addSection(Section section) {
        section.setSectionId(makeId());
        sectionMapper.addSection(section);
    }

    private String makeId() {
        return "SE" + System.currentTimeMillis();
    }

    @Override
    public void updateSection(Section section) {
        sectionMapper.updateSection(section);

    }

    @Override
    public void deleteSection(String sectionId) {
        sectionMapper.deleteSection(sectionId);

    }

    @Override
    public List<Section> getSectionList(String articleId) {
        return sectionMapper.getSectionList(articleId);
    }
}
